home *** CD-ROM | disk | FTP | other *** search
- program plasma2;
- {
- Plasma dude #2
- - by Bjarke Viksφe
- feb 1994
-
- THIS PROGRAM WAS CODED BY BJARKE VIKS0E.
- YOU ARE FREE TO DO WHATEVER YOU WANT WITH THIS PIECE OF CODE.
- E-MAIL ME AT: dat92230@rix02.lyngbyes.dk IN 1994 FOR CHAT AND CODE.
-
- Too easy. Who can't do plasma these days. Pretty fast, though.
- No cycling colours this time, eh?
- }
-
- uses
- DEMOINIT;
-
- const
- DEBUG = FALSE;
-
- var
- o1,o2,p1,p2 : byte;
- q1,q2 : byte;
- sinustabel : array[0..255] of byte;
-
- const
- display1 : integer = $0000;
- display2 : integer = $4000;
-
-
- (*------------------------------------------------*)
-
- procedure SwapDisplay;
- begin
- asm
- mov ax,display1
- mov dx,display2
- mov display1,dx
- mov display2,ax
- end;
- SetAddress(Ptr(SEGA000,display2));
- end;
-
-
- (*------------------------------------------------*)
-
- procedure SetupSinus;
- var
- i : integer;
- v, vadd : real;
- begin
- v:=0.0;
- vadd:=(2.0*pi/256.0);
- for i:=0 to 255 do
- begin
- sinustabel[i]:=round(sin(v)*63)+64;
- v:=v+vadd;
- end;
- end;
-
- procedure SetColors;
- var
- i : integer;
- r,g,b : byte;
- begin
- r:=0; b:=0; g:=0;
- for i:=0 to 63 do begin
- setRGB(i,r,g,b);
- inc(r);
- end;
- for i:=64 to 127 do begin
- dec(r);
- setRGB(i,r,g,b);
- end;
- for i:=128 to 191 do begin
- setRGB(i,r,g,b);
- inc(r);
- inc(g);
- end;
- for i:=192 to 255 do begin
- dec(r);
- dec(g);
- setRGB(i,r,g,b);
- end;
- end;
-
-
- procedure SetupDemo;
- var
- i : integer;
- begin
- ClearWholeScreen;
- SetupSinus;
- SetColors;
-
- o1:=54; o2:=64;
- p1:=87; p2:=230;
- end;
-
-
- (*------------------------------------------------*)
-
- procedure PlasmaLife; assembler;
- var
- temp : byte;
- ypos : integer;
- asm
- mov al,p1
- mov q1,al
- mov al,p2
- mov q2,al
-
- mov es,SEGA000
- mov di,display1
- lea bx,sinustabel
- xor ax,ax
- mov dl,o1
- mov dh,o2
- mov ypos,100
- cld
- @yloop:
- mov al,q1
- xlat
- mov dl,al
- mov al,q2
- xlat
- mov dh,al
-
- push dx
- mov cx,80/2
- @xloop:
- mov al,dl
- xlat
- mov ah,al
- mov al,dh
- xlat
- add al,ah
- mov temp,al
- inc dl
- dec dh
-
- mov al,dl
- xlat
- mov ah,al
- mov al,dh
- xlat
- add ah,al
- mov al,temp
- inc dl
-
- stosw
- dec cx
- jnz @xloop
- pop dx
- sub q1,2
- add q2,1
- dec ypos
- jnz @yloop
- end;
-
- procedure ChangeAngle;
- begin
- dec(o1,2);
- inc(o2,1);
- inc(p1,1);
- dec(p2,2);
- end;
-
-
- (*------------------------------------------------*)
-
- procedure RunOnce;
- begin
- SwapDisplay;
- VBLANK;
- if DEBUG then setrgb(0,63,0,0);
- SetBitplanes(15);
- PlasmaLife;
- ChangeAngle;
- if DEBUG then setrgb(0,0,0,0);
- end;
-
-
- begin
- OpenScreen;
- SetLineRepeat(3);
- SetupDemo;
- while (not KeyPressed) do RunOnce;
- CloseScreen;
- end.
-